#include "acceptConn.h"

//引用
void acceptConn(int& maxfd, struct pollfd (&fds)[1024], int& lfd)
{
    std::cout << "新线程-新客户端连接" << std::endl;

    //接收连接, 添加到fds中
    int cfd = accept(lfd, nullptr, nullptr);
    for(int i = 0; i<1024; i++)
    {
        if(fds[i].fd == -1)
        {
            mtx.lock();
            fds[i].fd = cfd;
            maxfd = i > maxfd ? i : maxfd;
            mtx.unlock();
            break;
        }
    }
}
